3.13.11 \(\int \frac {(a+b \tan (e+f x))^2}{c+d \tan (e+f x)} \, dx\) [1211]

Optimal. Leaf size=103 \[ -\frac {b (b c-2 a d) x}{d^2}+\frac {c (b c-a d)^2 x}{d^2 \left (c^2+d^2\right )}-\frac {b^2 \log (\cos (e+f x))}{d f}+\frac {(b c-a d)^2 \log (c \cos (e+f x)+d \sin (e+f x))}{d \left (c^2+d^2\right ) f} \]

[Out]

-b*(-2*a*d+b*c)*x/d^2+c*(-a*d+b*c)^2*x/d^2/(c^2+d^2)-b^2*ln(cos(f*x+e))/d/f+(-a*d+b*c)^2*ln(c*cos(f*x+e)+d*sin
(f*x+e))/d/(c^2+d^2)/f

________________________________________________________________________________________

Rubi [A]
time = 0.09, antiderivative size = 103, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 4, integrand size = 25, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.160, Rules used = {3622, 3556, 3565, 3611} \begin {gather*} \frac {(b c-a d)^2 \log (c \cos (e+f x)+d \sin (e+f x))}{d f \left (c^2+d^2\right )}+\frac {c x (b c-a d)^2}{d^2 \left (c^2+d^2\right )}-\frac {b x (b c-2 a d)}{d^2}-\frac {b^2 \log (\cos (e+f x))}{d f} \end {gather*}

Antiderivative was successfully verified.

[In]

Int[(a + b*Tan[e + f*x])^2/(c + d*Tan[e + f*x]),x]

[Out]

-((b*(b*c - 2*a*d)*x)/d^2) + (c*(b*c - a*d)^2*x)/(d^2*(c^2 + d^2)) - (b^2*Log[Cos[e + f*x]])/(d*f) + ((b*c - a
*d)^2*Log[c*Cos[e + f*x] + d*Sin[e + f*x]])/(d*(c^2 + d^2)*f)

Rule 3556

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3565

Int[((a_) + (b_.)*tan[(c_.) + (d_.)*(x_)])^(-1), x_Symbol] :> Simp[a*(x/(a^2 + b^2)), x] + Dist[b/(a^2 + b^2),
 Int[(b - a*Tan[c + d*x])/(a + b*Tan[c + d*x]), x], x] /; FreeQ[{a, b, c, d}, x] && NeQ[a^2 + b^2, 0]

Rule 3611

Int[((c_) + (d_.)*tan[(e_.) + (f_.)*(x_)])/((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(c/(b*f))
*Log[RemoveContent[a*Cos[e + f*x] + b*Sin[e + f*x], x]], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d,
0] && NeQ[a^2 + b^2, 0] && EqQ[a*c + b*d, 0]

Rule 3622

Int[((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])^2/((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[d*(2*
b*c - a*d)*(x/b^2), x] + (Dist[d^2/b, Int[Tan[e + f*x], x], x] + Dist[(b*c - a*d)^2/b^2, Int[1/(a + b*Tan[e +
f*x]), x], x]) /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 0]

Rubi steps

\begin {align*} \int \frac {(a+b \tan (e+f x))^2}{c+d \tan (e+f x)} \, dx &=-\frac {b (b c-2 a d) x}{d^2}+\frac {b^2 \int \tan (e+f x) \, dx}{d}+\frac {(b c-a d)^2 \int \frac {1}{c+d \tan (e+f x)} \, dx}{d^2}\\ &=-\frac {b (b c-2 a d) x}{d^2}+\frac {c (b c-a d)^2 x}{d^2 \left (c^2+d^2\right )}-\frac {b^2 \log (\cos (e+f x))}{d f}+\frac {(b c-a d)^2 \int \frac {d-c \tan (e+f x)}{c+d \tan (e+f x)} \, dx}{d \left (c^2+d^2\right )}\\ &=-\frac {b (b c-2 a d) x}{d^2}+\frac {c (b c-a d)^2 x}{d^2 \left (c^2+d^2\right )}-\frac {b^2 \log (\cos (e+f x))}{d f}+\frac {(b c-a d)^2 \log (c \cos (e+f x)+d \sin (e+f x))}{d \left (c^2+d^2\right ) f}\\ \end {align*}

________________________________________________________________________________________

Mathematica [C] Result contains complex when optimal does not.
time = 0.16, size = 108, normalized size = 1.05 \begin {gather*} \frac {\frac {(a+i b)^2 \log (i-\tan (e+f x))}{i c-d}-\frac {(a-i b)^2 \log (i+\tan (e+f x))}{i c+d}+\frac {2 (b c-a d)^2 \log (c+d \tan (e+f x))}{d \left (c^2+d^2\right )}}{2 f} \end {gather*}

Antiderivative was successfully verified.

[In]

Integrate[(a + b*Tan[e + f*x])^2/(c + d*Tan[e + f*x]),x]

[Out]

(((a + I*b)^2*Log[I - Tan[e + f*x]])/(I*c - d) - ((a - I*b)^2*Log[I + Tan[e + f*x]])/(I*c + d) + (2*(b*c - a*d
)^2*Log[c + d*Tan[e + f*x]])/(d*(c^2 + d^2)))/(2*f)

________________________________________________________________________________________

Maple [A]
time = 0.22, size = 117, normalized size = 1.14

method result size
derivativedivides \(\frac {\frac {\left (a^{2} d^{2}-2 a b c d +b^{2} c^{2}\right ) \ln \left (c +d \tan \left (f x +e \right )\right )}{\left (c^{2}+d^{2}\right ) d}+\frac {\frac {\left (-a^{2} d +2 a b c +b^{2} d \right ) \ln \left (1+\tan ^{2}\left (f x +e \right )\right )}{2}+\left (a^{2} c +2 a b d -b^{2} c \right ) \arctan \left (\tan \left (f x +e \right )\right )}{c^{2}+d^{2}}}{f}\) \(117\)
default \(\frac {\frac {\left (a^{2} d^{2}-2 a b c d +b^{2} c^{2}\right ) \ln \left (c +d \tan \left (f x +e \right )\right )}{\left (c^{2}+d^{2}\right ) d}+\frac {\frac {\left (-a^{2} d +2 a b c +b^{2} d \right ) \ln \left (1+\tan ^{2}\left (f x +e \right )\right )}{2}+\left (a^{2} c +2 a b d -b^{2} c \right ) \arctan \left (\tan \left (f x +e \right )\right )}{c^{2}+d^{2}}}{f}\) \(117\)
norman \(\frac {\left (a^{2} c +2 a b d -b^{2} c \right ) x}{c^{2}+d^{2}}+\frac {\left (a^{2} d^{2}-2 a b c d +b^{2} c^{2}\right ) \ln \left (c +d \tan \left (f x +e \right )\right )}{\left (c^{2}+d^{2}\right ) d f}-\frac {\left (a^{2} d -2 a b c -b^{2} d \right ) \ln \left (1+\tan ^{2}\left (f x +e \right )\right )}{2 f \left (c^{2}+d^{2}\right )}\) \(120\)
risch \(\frac {2 i x a b}{i d -c}-\frac {a^{2} x}{i d -c}+\frac {x \,b^{2}}{i d -c}-\frac {2 i d \,a^{2} x}{c^{2}+d^{2}}-\frac {2 i d \,a^{2} e}{\left (c^{2}+d^{2}\right ) f}+\frac {4 i a b c x}{c^{2}+d^{2}}+\frac {4 i a b c e}{\left (c^{2}+d^{2}\right ) f}-\frac {2 i b^{2} c^{2} x}{\left (c^{2}+d^{2}\right ) d}-\frac {2 i b^{2} c^{2} e}{\left (c^{2}+d^{2}\right ) d f}+\frac {2 i b^{2} x}{d}+\frac {2 i b^{2} e}{d f}+\frac {d \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}-\frac {i d +c}{i d -c}\right ) a^{2}}{\left (c^{2}+d^{2}\right ) f}-\frac {2 \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}-\frac {i d +c}{i d -c}\right ) a b c}{\left (c^{2}+d^{2}\right ) f}+\frac {\ln \left ({\mathrm e}^{2 i \left (f x +e \right )}-\frac {i d +c}{i d -c}\right ) b^{2} c^{2}}{\left (c^{2}+d^{2}\right ) d f}-\frac {b^{2} \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right )}{d f}\) \(357\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((a+b*tan(f*x+e))^2/(c+d*tan(f*x+e)),x,method=_RETURNVERBOSE)

[Out]

1/f*((a^2*d^2-2*a*b*c*d+b^2*c^2)/(c^2+d^2)/d*ln(c+d*tan(f*x+e))+1/(c^2+d^2)*(1/2*(-a^2*d+2*a*b*c+b^2*d)*ln(1+t
an(f*x+e)^2)+(a^2*c+2*a*b*d-b^2*c)*arctan(tan(f*x+e))))

________________________________________________________________________________________

Maxima [A]
time = 0.53, size = 126, normalized size = 1.22 \begin {gather*} \frac {\frac {2 \, {\left (2 \, a b d + {\left (a^{2} - b^{2}\right )} c\right )} {\left (f x + e\right )}}{c^{2} + d^{2}} + \frac {2 \, {\left (b^{2} c^{2} - 2 \, a b c d + a^{2} d^{2}\right )} \log \left (d \tan \left (f x + e\right ) + c\right )}{c^{2} d + d^{3}} + \frac {{\left (2 \, a b c - {\left (a^{2} - b^{2}\right )} d\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right )}{c^{2} + d^{2}}}{2 \, f} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*tan(f*x+e))^2/(c+d*tan(f*x+e)),x, algorithm="maxima")

[Out]

1/2*(2*(2*a*b*d + (a^2 - b^2)*c)*(f*x + e)/(c^2 + d^2) + 2*(b^2*c^2 - 2*a*b*c*d + a^2*d^2)*log(d*tan(f*x + e)
+ c)/(c^2*d + d^3) + (2*a*b*c - (a^2 - b^2)*d)*log(tan(f*x + e)^2 + 1)/(c^2 + d^2))/f

________________________________________________________________________________________

Fricas [A]
time = 0.81, size = 137, normalized size = 1.33 \begin {gather*} \frac {2 \, {\left (2 \, a b d^{2} + {\left (a^{2} - b^{2}\right )} c d\right )} f x + {\left (b^{2} c^{2} - 2 \, a b c d + a^{2} d^{2}\right )} \log \left (\frac {d^{2} \tan \left (f x + e\right )^{2} + 2 \, c d \tan \left (f x + e\right ) + c^{2}}{\tan \left (f x + e\right )^{2} + 1}\right ) - {\left (b^{2} c^{2} + b^{2} d^{2}\right )} \log \left (\frac {1}{\tan \left (f x + e\right )^{2} + 1}\right )}{2 \, {\left (c^{2} d + d^{3}\right )} f} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*tan(f*x+e))^2/(c+d*tan(f*x+e)),x, algorithm="fricas")

[Out]

1/2*(2*(2*a*b*d^2 + (a^2 - b^2)*c*d)*f*x + (b^2*c^2 - 2*a*b*c*d + a^2*d^2)*log((d^2*tan(f*x + e)^2 + 2*c*d*tan
(f*x + e) + c^2)/(tan(f*x + e)^2 + 1)) - (b^2*c^2 + b^2*d^2)*log(1/(tan(f*x + e)^2 + 1)))/((c^2*d + d^3)*f)

________________________________________________________________________________________

Sympy [C] Result contains complex when optimal does not.
time = 0.63, size = 1025, normalized size = 9.95 \begin {gather*} \begin {cases} \frac {\tilde {\infty } x \left (a + b \tan {\left (e \right )}\right )^{2}}{\tan {\left (e \right )}} & \text {for}\: c = 0 \wedge d = 0 \wedge f = 0 \\\frac {i a^{2} f x \tan {\left (e + f x \right )}}{2 d f \tan {\left (e + f x \right )} - 2 i d f} + \frac {a^{2} f x}{2 d f \tan {\left (e + f x \right )} - 2 i d f} + \frac {i a^{2}}{2 d f \tan {\left (e + f x \right )} - 2 i d f} + \frac {2 a b f x \tan {\left (e + f x \right )}}{2 d f \tan {\left (e + f x \right )} - 2 i d f} - \frac {2 i a b f x}{2 d f \tan {\left (e + f x \right )} - 2 i d f} - \frac {2 a b}{2 d f \tan {\left (e + f x \right )} - 2 i d f} + \frac {i b^{2} f x \tan {\left (e + f x \right )}}{2 d f \tan {\left (e + f x \right )} - 2 i d f} + \frac {b^{2} f x}{2 d f \tan {\left (e + f x \right )} - 2 i d f} + \frac {b^{2} \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )} \tan {\left (e + f x \right )}}{2 d f \tan {\left (e + f x \right )} - 2 i d f} - \frac {i b^{2} \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 d f \tan {\left (e + f x \right )} - 2 i d f} - \frac {i b^{2}}{2 d f \tan {\left (e + f x \right )} - 2 i d f} & \text {for}\: c = - i d \\- \frac {i a^{2} f x \tan {\left (e + f x \right )}}{2 d f \tan {\left (e + f x \right )} + 2 i d f} + \frac {a^{2} f x}{2 d f \tan {\left (e + f x \right )} + 2 i d f} - \frac {i a^{2}}{2 d f \tan {\left (e + f x \right )} + 2 i d f} + \frac {2 a b f x \tan {\left (e + f x \right )}}{2 d f \tan {\left (e + f x \right )} + 2 i d f} + \frac {2 i a b f x}{2 d f \tan {\left (e + f x \right )} + 2 i d f} - \frac {2 a b}{2 d f \tan {\left (e + f x \right )} + 2 i d f} - \frac {i b^{2} f x \tan {\left (e + f x \right )}}{2 d f \tan {\left (e + f x \right )} + 2 i d f} + \frac {b^{2} f x}{2 d f \tan {\left (e + f x \right )} + 2 i d f} + \frac {b^{2} \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )} \tan {\left (e + f x \right )}}{2 d f \tan {\left (e + f x \right )} + 2 i d f} + \frac {i b^{2} \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 d f \tan {\left (e + f x \right )} + 2 i d f} + \frac {i b^{2}}{2 d f \tan {\left (e + f x \right )} + 2 i d f} & \text {for}\: c = i d \\\frac {a^{2} x + \frac {a b \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{f} - b^{2} x + \frac {b^{2} \tan {\left (e + f x \right )}}{f}}{c} & \text {for}\: d = 0 \\\frac {x \left (a + b \tan {\left (e \right )}\right )^{2}}{c + d \tan {\left (e \right )}} & \text {for}\: f = 0 \\\frac {2 a^{2} c d f x}{2 c^{2} d f + 2 d^{3} f} + \frac {2 a^{2} d^{2} \log {\left (\frac {c}{d} + \tan {\left (e + f x \right )} \right )}}{2 c^{2} d f + 2 d^{3} f} - \frac {a^{2} d^{2} \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 c^{2} d f + 2 d^{3} f} - \frac {4 a b c d \log {\left (\frac {c}{d} + \tan {\left (e + f x \right )} \right )}}{2 c^{2} d f + 2 d^{3} f} + \frac {2 a b c d \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 c^{2} d f + 2 d^{3} f} + \frac {4 a b d^{2} f x}{2 c^{2} d f + 2 d^{3} f} + \frac {2 b^{2} c^{2} \log {\left (\frac {c}{d} + \tan {\left (e + f x \right )} \right )}}{2 c^{2} d f + 2 d^{3} f} - \frac {2 b^{2} c d f x}{2 c^{2} d f + 2 d^{3} f} + \frac {b^{2} d^{2} \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 c^{2} d f + 2 d^{3} f} & \text {otherwise} \end {cases} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*tan(f*x+e))**2/(c+d*tan(f*x+e)),x)

[Out]

Piecewise((zoo*x*(a + b*tan(e))**2/tan(e), Eq(c, 0) & Eq(d, 0) & Eq(f, 0)), (I*a**2*f*x*tan(e + f*x)/(2*d*f*ta
n(e + f*x) - 2*I*d*f) + a**2*f*x/(2*d*f*tan(e + f*x) - 2*I*d*f) + I*a**2/(2*d*f*tan(e + f*x) - 2*I*d*f) + 2*a*
b*f*x*tan(e + f*x)/(2*d*f*tan(e + f*x) - 2*I*d*f) - 2*I*a*b*f*x/(2*d*f*tan(e + f*x) - 2*I*d*f) - 2*a*b/(2*d*f*
tan(e + f*x) - 2*I*d*f) + I*b**2*f*x*tan(e + f*x)/(2*d*f*tan(e + f*x) - 2*I*d*f) + b**2*f*x/(2*d*f*tan(e + f*x
) - 2*I*d*f) + b**2*log(tan(e + f*x)**2 + 1)*tan(e + f*x)/(2*d*f*tan(e + f*x) - 2*I*d*f) - I*b**2*log(tan(e +
f*x)**2 + 1)/(2*d*f*tan(e + f*x) - 2*I*d*f) - I*b**2/(2*d*f*tan(e + f*x) - 2*I*d*f), Eq(c, -I*d)), (-I*a**2*f*
x*tan(e + f*x)/(2*d*f*tan(e + f*x) + 2*I*d*f) + a**2*f*x/(2*d*f*tan(e + f*x) + 2*I*d*f) - I*a**2/(2*d*f*tan(e
+ f*x) + 2*I*d*f) + 2*a*b*f*x*tan(e + f*x)/(2*d*f*tan(e + f*x) + 2*I*d*f) + 2*I*a*b*f*x/(2*d*f*tan(e + f*x) +
2*I*d*f) - 2*a*b/(2*d*f*tan(e + f*x) + 2*I*d*f) - I*b**2*f*x*tan(e + f*x)/(2*d*f*tan(e + f*x) + 2*I*d*f) + b**
2*f*x/(2*d*f*tan(e + f*x) + 2*I*d*f) + b**2*log(tan(e + f*x)**2 + 1)*tan(e + f*x)/(2*d*f*tan(e + f*x) + 2*I*d*
f) + I*b**2*log(tan(e + f*x)**2 + 1)/(2*d*f*tan(e + f*x) + 2*I*d*f) + I*b**2/(2*d*f*tan(e + f*x) + 2*I*d*f), E
q(c, I*d)), ((a**2*x + a*b*log(tan(e + f*x)**2 + 1)/f - b**2*x + b**2*tan(e + f*x)/f)/c, Eq(d, 0)), (x*(a + b*
tan(e))**2/(c + d*tan(e)), Eq(f, 0)), (2*a**2*c*d*f*x/(2*c**2*d*f + 2*d**3*f) + 2*a**2*d**2*log(c/d + tan(e +
f*x))/(2*c**2*d*f + 2*d**3*f) - a**2*d**2*log(tan(e + f*x)**2 + 1)/(2*c**2*d*f + 2*d**3*f) - 4*a*b*c*d*log(c/d
 + tan(e + f*x))/(2*c**2*d*f + 2*d**3*f) + 2*a*b*c*d*log(tan(e + f*x)**2 + 1)/(2*c**2*d*f + 2*d**3*f) + 4*a*b*
d**2*f*x/(2*c**2*d*f + 2*d**3*f) + 2*b**2*c**2*log(c/d + tan(e + f*x))/(2*c**2*d*f + 2*d**3*f) - 2*b**2*c*d*f*
x/(2*c**2*d*f + 2*d**3*f) + b**2*d**2*log(tan(e + f*x)**2 + 1)/(2*c**2*d*f + 2*d**3*f), True))

________________________________________________________________________________________

Giac [A]
time = 0.57, size = 126, normalized size = 1.22 \begin {gather*} \frac {\frac {2 \, {\left (a^{2} c - b^{2} c + 2 \, a b d\right )} {\left (f x + e\right )}}{c^{2} + d^{2}} + \frac {{\left (2 \, a b c - a^{2} d + b^{2} d\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right )}{c^{2} + d^{2}} + \frac {2 \, {\left (b^{2} c^{2} - 2 \, a b c d + a^{2} d^{2}\right )} \log \left ({\left | d \tan \left (f x + e\right ) + c \right |}\right )}{c^{2} d + d^{3}}}{2 \, f} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*tan(f*x+e))^2/(c+d*tan(f*x+e)),x, algorithm="giac")

[Out]

1/2*(2*(a^2*c - b^2*c + 2*a*b*d)*(f*x + e)/(c^2 + d^2) + (2*a*b*c - a^2*d + b^2*d)*log(tan(f*x + e)^2 + 1)/(c^
2 + d^2) + 2*(b^2*c^2 - 2*a*b*c*d + a^2*d^2)*log(abs(d*tan(f*x + e) + c))/(c^2*d + d^3))/f

________________________________________________________________________________________

Mupad [B]
time = 5.60, size = 115, normalized size = 1.12 \begin {gather*} \frac {\ln \left (\mathrm {tan}\left (e+f\,x\right )-\mathrm {i}\right )\,\left (-a^2\,1{}\mathrm {i}+2\,a\,b+b^2\,1{}\mathrm {i}\right )}{2\,f\,\left (c+d\,1{}\mathrm {i}\right )}+\frac {\ln \left (\mathrm {tan}\left (e+f\,x\right )+1{}\mathrm {i}\right )\,\left (-a^2+a\,b\,2{}\mathrm {i}+b^2\right )}{2\,f\,\left (d+c\,1{}\mathrm {i}\right )}+\frac {\ln \left (c+d\,\mathrm {tan}\left (e+f\,x\right )\right )\,{\left (a\,d-b\,c\right )}^2}{d\,f\,\left (c^2+d^2\right )} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((a + b*tan(e + f*x))^2/(c + d*tan(e + f*x)),x)

[Out]

(log(tan(e + f*x) - 1i)*(2*a*b - a^2*1i + b^2*1i))/(2*f*(c + d*1i)) + (log(tan(e + f*x) + 1i)*(a*b*2i - a^2 +
b^2))/(2*f*(c*1i + d)) + (log(c + d*tan(e + f*x))*(a*d - b*c)^2)/(d*f*(c^2 + d^2))

________________________________________________________________________________________